/**
 * A Server is responsible for a single share
 * of the secret distributed by the dealer.
 * @author jwallrab
 *
 */
public class Server {

	NetworkCommunicator net;
	Share myShare;
	
	public Server(int p){
		
		net = new NetworkCommunicator(p);
		receiveShare();
		
		System.out.println("My Share is: " + myShare.toString());
	}
	
	public void receiveShare(){
		
		try {
			net.openServerSocket();
			net.openConnection();
			myShare = (Share) net.receiveObject();
			net.closeServerSocket();
		} catch (Exception e) {
			System.out.println("Error: Could not receive share from dealer");
			System.exit(1);
		}
	}
}
